package board.action;
import board.dao.BoardDAO;
import board.model.BoardVo;
import board.model.BoardFiles;
import board.dao.FileDAO;
import comment.model.CommentVo;
/*import comment.dao.CommentDAO;*/ 
import java.util.Map;
import java.util.HashMap;
import java.util.List;
import java.util.ArrayList;
import com.util.FileUtil;
/*import comment.action.PagingAction;*/

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.Preparable;
import com.opensymphony.xwork2.ModelDriven;
/*import comment.dao.CommentDAO;*/

public class ViewAction implements Action,Preparable,ModelDriven{
	BoardVo boardVo;
	BoardDAO boardDAO = BoardDAO.getInstance();
	/*CommentVo commentVo; 
	CommentDAO commentDAO = CommentDAO.getInstance();*/
	private List<CommentVo> commentlist = new ArrayList<CommentVo>();
	
	
	BoardFiles boardFiles;
	FileDAO fileDAO = FileDAO.getInstance();
	private List<BoardFiles> fileList = new ArrayList();
	FileUtil fileUtil = new FileUtil();
	private int currentPage;
	private String bname ="bbs"; 
	private int seq ; 
	private int currrentPage = 1 ; 
	private int totalCount; 
	private int blockCount = 10; 
	private int blockPage = 5 ; 
	private String pagingHtml;
	private PagingAction commentpage;
		
	public String execute() throws Exception {
		
		/*HashMap commentmap = new HashMap();
		commentmap.put("seq", seq);
		
		totalCount = commentDAO.getRowCount(commentmap); 

		commentpage = new PagingAction(currentPage, totalCount, blockCount, blockPage);
		pagingHtml = commentpage.getPagingHtml().toString();
		System.out.println(pagingHtml);
		int lastCount = totalCount;
		
		if(commentpage.getEndCount() < totalCount){
			lastCount = commentpage.getEndCount() + 1;
		}
		commentmap.put("seq", boardVo.getSeq()); 
		commentmap.put("start", commentpage.getStartCount());
		commentmap.put("end", lastCount);
		commentlist = commentDAO.list(commentmap);		
*/		
		
		boardVo = boardDAO.selectBoard(boardVo);
		Map map = new HashMap();
		map.put("seq",boardVo.getSeq());
		boardDAO.updateHit(map);
		fileList = fileDAO.list(boardVo.getSeq());
		return SUCCESS;
	}
	
	
	public List<CommentVo> getCommentlist() {
		return commentlist;
	}


	public void setCommentlist(List<CommentVo> commentlist) {
		this.commentlist = commentlist;
	}


	public int getCurrrentPage() {
		return currrentPage;
	}


	public void setCurrrentPage(int currrentPage) {
		this.currrentPage = currrentPage;
	}


	public FileUtil getFileUtil() {
		return fileUtil;
	}


	public void setFileUtil(FileUtil fileUtil) {
		this.fileUtil = fileUtil;
	}


	public List<BoardFiles> getFileList() {
		return fileList;
	}


	public void setFileList(List<BoardFiles> fileList) {
		this.fileList = fileList;
	}


	public String getBname() {
		return bname;
	}

	public void setBname(String bname) {
		this.bname = bname;
	}

	public int getCurrentPage() {
		return currentPage;
	}

	public void setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
	}

	public void prepare() throws Exception {
		boardVo = new BoardVo();
	}
	
	public Object getModel() {
		return boardVo;
	}

	public BoardVo getBoardVo() {
		return boardVo;
	}

	public void setBoardVo(BoardVo boardVo) {
		this.boardVo = boardVo;
	}
	/*public CommentVo getCommentVo() {
		return commentVo;
	}


	public void setCommentVo(CommentVo commentVo) {
		this.commentVo = commentVo;
	}


	public CommentDAO getCommentDAO() {
		return commentDAO;
	}


	public void setCommentDAO(CommentDAO commentDAO) {
		this.commentDAO = commentDAO;
	}


	public comment.action.PagingAction getCommentpage() {
		return commentpage;
	}


	public void setCommentpage(comment.action.PagingAction commentpage) {
		this.commentpage = commentpage;
	}*/


}
